﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DOTNETGROUP.Entities;
using DOTNETGROUP.Data;
using System.Data;

public partial class Chi_Tiet_Nhom_Video : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            Pager1.CurrentIndex = 1;
            HienThi_Video(Pager1.CurrentIndex);
        }
    }
    public string GetTieuDe(object Char)
    {
        string s = Char.ToString();
        return Common.ConvertToUnSign(s);
    }


    protected void HienThi_Video(int pageNo)
    {
        
        LoaiVideo ent_LoaiVideo = DataRepository.LoaiVideoProvider.GetById(Convert.ToInt32(Request.Params["Id"]));
        lblLoaiVideo.Text = ent_LoaiVideo.TenLoaiVideo;
        linkloaitin.NavigateUrl = "~/VideoCatalog/" + GetTieuDe(ent_LoaiVideo.TenLoaiVideo) + "_" + ent_LoaiVideo.Id +
                                  ".aspx";
        if (ent_LoaiVideo != null)
        {
            int TotalRows = 0;
            string WhereClause = "IdLoaiVideo= " + ent_LoaiVideo.Id;
            DataSet dsVideo = DataRepository.Provider.ExecuteDataSet("Video_GetPaged", WhereClause, "NgayCapNhat DESC", pageNo - 1, Pager1.PageSize);
            dtlVideo.DataSource = dsVideo;
            dtlVideo.DataBind();
            try
            {
                TotalRows = Convert.ToInt32(dsVideo.Tables[1].Rows[0][0]);
            }
            catch (Exception)
            {
            }
            Pager1.ItemCount = TotalRows;
            if (TotalRows <= Pager1.PageSize)
                Pager1.Visible = false;
            else
                Pager1.Visible = true;
        }

    }

    protected void Pager1_Command(object sender, CommandEventArgs e)
    {
        int currnetPageIndex = Convert.ToInt32(e.CommandArgument);
        Pager1.CurrentIndex = currnetPageIndex;
        HienThi_Video(currnetPageIndex);
    }

    public string GetLoaiVideo(object idLoaiVideo)
    {
        int id = Convert.ToInt32(idLoaiVideo.ToString());
        LoaiVideo ent_LoaiVideo = DataRepository.LoaiVideoProvider.GetById(id);
        return ent_LoaiVideo.TenLoaiVideo;
    }
}
